package servlet.web;

import java.io.IOException;
import java.util.List;

import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ejb.bl.MusicStoreBLRemote;

/**
 * Servlet implementation class ViewCdDetails
 */
@WebServlet("/ViewCdDetails")
public class ViewCdDetails extends HttpServlet {
	private static final long serialVersionUID = 1L;
	@EJB(name = "MusicStoreStalessBean")
	private MusicStoreBLRemote MusicStoreBLBean;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public ViewCdDetails() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String cdId = request.getParameter("cdId");
		List list = MusicStoreBLBean.loadSongByCdId(cdId);
		request.setAttribute("cdSong", list);

		// dispatching request to jsp page
		String strViewPage = "/pages/client/showCdSong.jsp";
		RequestDispatcher dispatcher = request.getRequestDispatcher(strViewPage);
		if (dispatcher != null) {
			dispatcher.forward(request, response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}
}
